package com.a3dweijing.wetouch2.adapter;

import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import com.a3dweijing.wetouch2.R;
import com.a3dweijing.wetouch2.Util.ImageLoaderUtil;
import com.a3dweijing.wetouch2.bean.ExpoonVideo;
import com.a3dweijing.wetouch2.callback.OnClick;

import java.util.List;

/**
 * 适配器用于网展科技的列表上
 * Created by Yxd on 2017/11/14.
 */

public class SpecialListBottomRecAdapter2 extends RecyclerView.Adapter<SpecialListBottomRecAdapter2.MyViewHolder> {

    private List<ExpoonVideo> videoList;
    private OnClick onClick;

    public void setOnClick(OnClick onClick) {
        this.onClick = onClick;
    }

    public SpecialListBottomRecAdapter2(List<ExpoonVideo> videoList) {

        this.videoList = videoList;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_special_list,parent,false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        final ExpoonVideo video=videoList.get(position);
        holder.time.setText(video.getUploadDatetime());
        ImageLoaderUtil.getLoader().loadImg2(video.getVideoShowImg(),holder.pic);
        holder.name.setText(video.getVideoName());
        holder.content.setText(video.getVideoDescribe());
        holder.like.setText(video.getLikeCount()+"");
        holder.play.setText(video.getClickNum()+"");
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onClick!=null ){
                    onClick.onclick(position,video);
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        return videoList.size();
    }

    class MyViewHolder extends ViewHolder {
        TextView time;
        ImageView pic;
        TextView name;
        TextView content;
        TextView like;
        TextView play;
        TextView comment;
        public MyViewHolder(View itemView) {
            super(itemView);
            time= (TextView) itemView.findViewById(R.id.special_list_time);
            pic= (ImageView) itemView.findViewById(R.id.special_list_pic);
            name= (TextView) itemView.findViewById(R.id.special_list_name);
            content= (TextView) itemView.findViewById(R.id.special_list_content);
            like= (TextView) itemView.findViewById(R.id.special_list_like);
            play= (TextView) itemView.findViewById(R.id.special_list_play);
            comment= (TextView) itemView.findViewById(R.id.special_list_comment);
        }
    }
}
